<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <style>
        .shadow{
            width: 200px;
            height: 200px;
            background-color: rgba(0,0,0,0.5);
            position: absolute;
            left: 100px;
            top: 100px;
        }
        asd{
            display: block;
            width: 100px;
            height: 100px;
            background-color: #6ff;
        }
    </style>
</head>
<body>
    <asd>123123</asd> 
    <button class="dispatch">派发事件</button>
    <div class="shadow"></div>
</body>
<script>
  

    var shadow = document.getElementsByClassName("shadow")[0];

    function JSFineHandler(){
        console.log("JS太有意思了");
    }

    // 添加自定义事件
    shadow.addEventListener("JS_FINE",JSFineHandler);

    // 删除自定义事件
    // shadow.removeEventListener("JS_FINE",JSFineHandler)

    // 向指定元素派发自定义事件
    var e = new Event("JS_FINE");
    shadow.dispatchEvent(e);


    

</script>
</html>